package com.frxuexi.mysign.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_base.entity.SignBeanItem
import com.frxuexi.mysign.R

class MySignAdapter:BaseQuickAdapter<SignBeanItem,BaseViewHolder>(R.layout.item_mysign) {

    override fun convert(helper: BaseViewHolder, item: SignBeanItem) {
        val dateTime = item.morningCheckIn.split(" ")
        helper.setText(R.id.signitem_date,dateTime[0].replaceFirst("-","年").replaceFirst("-","月").plus("日"))
        helper.setText(R.id.signitem_time,dateTime[1])
        helper.getView<TextView>(R.id.signitem_status).apply {
            setText(item.status)
            when(item.status){
                "正常"->{
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_status)
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.green))
                }
                "迟到"->{
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_weihu)
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.darkorange))
                }
                "早退"->{
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_zhanyong)
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.blue))
                }
            }
        }
    }

}